package soft863.com.demo1007;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import soft863.com.mr3.mvMapper;
import soft863.com.mr3.mvReducer;
import soft863.com.mr3.mv_rate;

import java.io.IOException;

public class fDr {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        //通过job对象对map类和reducer类进行封装
        Job job = Job.getInstance(new Configuration());
        //指定程序入口
        job.setJarByClass(fDr.class);

        //指定Mapper类
        job.setMapperClass(fMap.class);
        //指定map输出key的类型
        job.setMapOutputKeyClass(Text.class);
        //指定map输出的value类型
        job.setMapOutputValueClass(Flow.class);


        job.setPartitionerClass(FlowPartition.class);
        job.setNumReduceTasks(8);

        //指定Reducer类
        job.setReducerClass(fRd.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Flow.class);


        //指定要处理的数据
        FileInputFormat.setInputPaths(job, new

                Path("input//phone_info.txt"));
        //指定处理后的结果保存的目录
        FileOutputFormat.setOutputPath(job, new

                Path("output//data11013"));
        //等待mapreduce处理结束
        boolean boo = job.waitForCompletion(true);

        System.exit(boo ? 0 : 1);
    }
}
